package model

import (
	"time"
)

// Member 会员信息表

// MemberLevel 会员等级配置表
type MemberLevel struct {
	ID               uint64    `json:"id" gorm:"primaryKey;autoIncrement;comment:等级ID"`
	LevelCode        int       `json:"levelCode" gorm:"not null;uniqueIndex;comment:等级编码：1普通 2银卡 3金卡 4钻石"`
	LevelName        string    `json:"levelName" gorm:"not null;size:20;comment:等级名称"`
	DiscountRate     float64   `json:"discountRate" gorm:"not null;comment:折扣率：如0.95表示9.5折"`
	RechargeGiftRate float64   `json:"rechargeGiftRate" gorm:"default:0.00;comment:充值赠送比例"`
	MinRecharge      float64   `json:"minRecharge" gorm:"default:0.00;comment:最低充值金额"`
	Description      string    `json:"description" gorm:"size:255;comment:描述"`
	Status           int       `json:"status" gorm:"default:1;comment:状态：1启用 0禁用"`
	CreatedAt        time.Time `json:"createdAt" gorm:"comment:创建时间"`
	UpdatedAt        time.Time `json:"updatedAt" gorm:"comment:更新时间"`
}

func (MemberLevel) TableName() string {
	return "member_levels"
}

// MemberSearch 会员查询参数
type MemberSearch struct {
	MemberName  string `json:"memberName" form:"memberName"`
	Phone       string `json:"phone" form:"phone"`
	MemberLevel int    `json:"memberLevel" form:"memberLevel"`
	Status      int    `json:"status" form:"status"`
	StartDate   string `json:"startDate" form:"startDate"`
	EndDate     string `json:"endDate" form:"endDate"`
}

// MemberCreate 会员创建参数
type MemberCreate struct {
	MemberName      string  `json:"memberName" binding:"required"`
	Phone           string  `json:"phone" binding:"required"`
	InitialRecharge float64 `json:"initialRecharge"`
	Remark          string  `json:"remark"`
}

// MemberUpdate 会员更新参数
type MemberUpdate struct {
	ID         uint64 `json:"id" binding:"required"`
	MemberName string `json:"memberName"`
	Phone      string `json:"phone"`
	Status     int    `json:"status"`
	Remark     string `json:"remark"`
}

// MemberRecharge 会员充值参数
type MemberRecharge struct {
	MemberID       uint64  `json:"memberId" binding:"required"`
	RechargeAmount float64 `json:"rechargeAmount" binding:"required,min=100"`
	PaymentMethod  int     `json:"paymentMethod" binding:"required"`
	Remark         string  `json:"remark"`
}

// MemberConsumption 会员消费参数
type MemberConsumption struct {
	MemberID          uint64  `json:"memberId" binding:"required"`
	ConsumptionAmount float64 `json:"consumptionAmount" binding:"required,min=0.01"`
	ProjectType       int     `json:"projectType" binding:"required"`
	ProjectName       string  `json:"projectName"`
	Remark            string  `json:"remark"`
}

// MemberBalanceResp 会员余额响应
type MemberBalanceResp struct {
	MemberID    uint64  `json:"memberId"`
	MemberName  string  `json:"memberName"`
	Phone       string  `json:"phone"`
	MemberLevel int     `json:"memberLevel"`
	Balance     float64 `json:"balance"`
}
